﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using CellphoneRepair.Entities;
using DevExpress.XtraEditors;

namespace CellphoneRepair.Forms
{
    public partial class Kehuselector : DevExpress.XtraEditors.XtraForm
    {
        public Kehuselector()
        {
            InitializeComponent();
        }

        private List<Kehu> list;

        private void Kehuselector_Load(object sender, EventArgs e)
        {
            using (KehuBll bll = new KehuBll())
            {
                kehuBindingSource.DataSource =list = bll.GetAll();
            }
        }

        private void textEdit1_EditValueChanged(object sender, EventArgs e)
        {
            var filist =
                list.Where(
                    o =>
                        o.Xingming.Contains(textEdit1.Text) || o.Phoneno.Contains(textEdit1.Text) ||
                        o.Qq.Contains(textEdit1.Text));
            kehuBindingSource.DataSource = filist;
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            var editList = this.Tag as EditList;
            if (editList != null) editList.CurKehu = kehuBindingSource.Current as Kehu;
            this.DialogResult = DialogResult.OK;
        }
    }
}